//
//  CHOutlineView.h
//  Chocolat
//
//  Created by Pieter Omvlee on 3/30/08.
//  Copyright 2008 Bohemian Coding. All rights reserved.
//

#import <Cocoa/Cocoa.h>

/*!
 * @class CHOutlineView
 * @abstract Subclass of NSOutlineView to display disclosuretriangles and handle keyEvents
 * @discussion The delegate only has to implement two simple methods to get it working
 * See the delegate for more details
 * 
 */
@interface CHOutlineView : NSOutlineView {

}

@end

/*!
 * @protocol CHOutlineViewDelegate
 * @abstract Informal protocol for CHOutlineView
 */
@interface NSObject (CHOutlineViewDelegate)

/*!
 * @method outlineView:shouldShowDisclosureTriangleForItem:
 * @param outlineView the outlineview
 * @param item the item for which to show the disclosureTraingle
 * Return YES to show the traingle.
 */
- (BOOL)outlineView:(NSOutlineView *)outlineView shouldShowDisclosureTriangleForItem:(id)item;

/*!
 * @method outlineView:handleKeyEvent:
 * @param olv the outlineView
 * @param anEvent the event which the delegate can process
 * Returns YES if you processed the event and want to prevent the outlineview from doing anything with it.
 */
- (BOOL)outlineView:(NSOutlineView *)olv handleKeyEvent:(NSEvent *)anEvent;
@end

@interface NSOutlineView (NSOutlineViewAdditions)
- (NSArray*)allSelectedItems;
- (void)selectItems:(NSArray*)items byExtendingSelection:(BOOL)extend;
- (void)selectItem:(id)item byExtendingSelection:(BOOL)extend;
- (void)selectItem:(id)item;
@end

@interface CHTableView : NSTableView {
  
}

@end

@interface NSObject (CHTableViewDelegate)
- (BOOL)tableView:(NSTableView *)tableView handleKeyEvent:(NSEvent *)anEvent;
- (BOOL)tableViewPoofEffect:(NSTableView *)tv;
@end